<template>
  <a-popconfirm
    title="props.title"
    cancel-text="取消"
    placement="bottomRight"
    v-model:open="open"
  >
    <template #okButton>
      <a-button type="primary" size="small" @click="confirm" :loading="loading">
        确定
      </a-button>
    </template>
    <a-button type="link" style="padding: 4px 6px" @click="onOpen">
      删除
    </a-button>
  </a-popconfirm>
</template>
<script setup>
import { ref } from 'vue'
// import { updateFileInfo, getChildFileCount } from '@/api/db.js'
// import { useDataSourceManager } from './provide-context.js'
/**
 * 外部参数
 */
let props = defineProps({
  id: {
    type: String,
    required: true,
  },
  title: { type: String },
})
/**
 * 事件定义
 */
let emit = defineEmits(['operated'])
/**
 * 全局
 */

// let { update } = useDataSourceManager()
/**
 * 操作
 */
let loading = ref(false)
let open = ref(false)
async function confirm() {
  loading.value = true
  try {
    // await updateFileInfo({
    //   dataId: props?.id,
    //   effectFlag: 0,
    // })
    open.value = false
    emit('operated')
    // await update()
  } catch (e) {}
  loading.value = false
}
/**
 * 打开气泡
 */
function onOpen() {
  open.value = true
}
</script>
<style lang="less" scoped></style>
